package JAVA300.第十一章多线程;

import java.sql.Time;
import java.util.*;

/**
 * 高级主题1--闹钟
 * 借助Time和TimerTask
 */
public class thread_19_others_1Time01 {
    public static void main(String[] args) {
        Timer timer = new Timer();
        //只执行一次
        //timer.schedule(new MyTask(),1000);
        //固定频率执行
        //timer.schedule(new MyTask(),1000,2000);
        //指定时间执行--月份从0开始
        Calendar cal = new GregorianCalendar(2020,8,18,8,45);
        timer.schedule(new MyTask(),cal.getTime(),2000);

    }
}

class MyTask extends TimerTask{
    @Override
    public void run() {
        for (int i=0;i<10;i++){
            System.out.println("这是TimerTask实现类");
        }
        System.out.println("------end---------");
    }
}

